package com.framework.modules.job.task;

import com.framework.entity.ter.TerMerchantReport;
import com.framework.service.DistribuService;
import com.framework.service.MerchantService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 处理机器
 * @author wq
 */
@Transactional(rollbackFor = Exception.class)
@Component("reportBaiyiTerminalTask")
@Slf4j
public class ReportBaiyiTerminalTask {

    @Autowired
    private MerchantService merchantService;

    @Autowired
    private DistribuService distribuService;

    public void reportBaiyiTerminal() {
        List<TerMerchantReport> terMerchantReports = merchantService.checkMerchantAndDis();
        for (TerMerchantReport report : terMerchantReports) {
            Long agentId = distribuService.queryTerminalOwn(report.getSn());

            if(!report.getAgentId().equals(agentId)){
                distribuService.disTerminal(report.getSn(),report.getAgentId(),report.getDeptId());
            }
        }


    }

}
